<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的团队</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="../css/aui.2.0.css">
    <link rel="stylesheet" href="../css/reset.css">
     <link rel="stylesheet" href="../css/alert.css">
    <link rel="stylesheet" href="../css/common1.css">
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/lessstyle.css">
</head>
<body>
<header class="aui-bar aui-bar-nav" id="aui-header">
    <div class="aui-col-xs-3 my-col-xs-3">
        <i class="aui-iconfont aui-icon-left"></i>
    </div>
    <div class="aui-title my-aui-title">我的团队</div>
</header>
<nav>
	<div class="levelcon">
		<div class="samefrade pitch"></div>
		<div class="samefrade"></div>
	</div>
    <div class="myteam-info-entry" id="myteam-info-entry">
        <script type="text/x-handlebars-template" id="myteam-template">
        <ul class="myteam-info-list">
            <li>
                <a href="javascript:;" class="display-box">
                    <span>用户手机</span>
                    <span>用户姓名</span>
                    <span>状态</span>
                    <span>注册时间</span>
                </a>
            </li>
            {{#each data}}
            <li>
                <a href="javascript:;" class="display-box">
                    <span>{{userPhone}}</span>
                    <span>{{userNickName}}</span>
                    <span>开店成功</span>
                    <span>{{Intercept createTime}}</span>
                </a>
            </li>
            {{/each}}
        </ul>
        </script>
    </div>
</nav>
 <div class="loading">加载更多...</div>
 <div class="no-info">没有更多信息了...</div>
<script src="../js/jquery-3.0.0.min.js"></script>
<script src="../js/handlebars-v4.0.10.js"></script>
<script src="../js/config.js"></script>
<script src="../js/function.js"></script>
<script src="../js/common.js"></script>
<script src="../js/alert.js"></script>

<script>
    var a=$('#myteam-template').html();
    var b=Handlebars.compile(a);
    var type = 1;
    
	
    Handlebars.registerHelper('Intercept',function (value) {
        if (value.length>=10){
            return value.substring(10,0)
        }else {
            return value;
        }
    })
	
    var range = 200, //距下边界长度/单位px
    	maxnum = 0, //设置课程总数
        totalheight = 0,
        seckillFlag=false,
        seckillOffset = 0,
        seckillLength = 5,
        totalSeckill = 0, //数据总条数
        searchName=null,
        flag = 0,
        start = 0,
        pageLength = 20,
        num = 0;
    ajaxdata();
    
    
 /*    $(window).on('scroll',function () {
        var srollPos = $(window).scrollTop(); //滚动条距顶部距离(页面超出窗口的高度)
        //console.log("滚动条到顶部的垂直高度: " + $(document).scrollTop());
        //console.log("页面的文档高度 ："+$(document).height());
        //console.log('浏览器的高度：'+$(window).height());
        totalheight = parseFloat($(window).height()) + parseFloat(srollPos);

        if (num>=maxnum){
            return;
        }
        if (($(document).height()-range)<=totalheight&&num<maxnum){
            //这里不能使用模板填充，应该是append()....
            ajaxdata();
        }
    });
   */
    function ajaxdata(){
    	 if (flag){
             return;
         }
    	$.ajax({
            url:C.marketInterface.myteam,
            type:'GET',
            data:{
                token:C.marketToken,
                type:type,
              /*   start:start,
                length:pageLength */
            },
            datatype:'json',
            success:function (data) {
                if(data.result=='success'){
                	/*  num++;
                    // var data=data.data;
                    console.log(data);
                    maxnum=data.count1;
                    start=num*pageLength; */
                   
                    $(".samefrade").eq(0).html('一级店主('+data.count1+')');
                    $(".samefrade").eq(0).attr('count',data.count1);
                    $(".samefrade").eq(1).html('二级店主('+data.count2+')');
                    $(".samefrade").eq(1).attr('count',data.count2);
                    
                    if (data.data.length>0){
                    	 $('#myteam-info-entry').html(b(data))
                    }else{
                    	 $(".no-info").show();
                         //num=maxnum+1;
                    }
                    
                    flag=0;
                }else if(data.result=='login'){
                	dialog.tusiError('登入过期，请重新登入！');
                    againLogin();
                }else {
                	dialog.tusiError(data.errorMsg);
                }
            },
            error:function () {
            	dialog.tusiError('工作人员正在恢复中...');
            }
        });
    }
    var count = '';
 
	   $(".samefrade").click(function(){
	    	$(".samefrade").removeClass('pitch');
	    	$(this).addClass('pitch');
	    	console.log($(this).index())
	    	 count= $(this).attr('count');
	    	if($(this).index() == "1"){
	    		type = 2;
	    		
	    		/* 
	    		  maxnum=count;
                  start=num*pageLength;
                  if(maxnum == 0){
                      $(".no-info").show();
                  } */
                  $("#myteam-info-entry").empty();
	    		ajaxdata();
	    		
	    	}else{
	    		/*  maxnum=count;
                 start=num*pageLength;
                 if(maxnum == 0){
                     $(".no-info").show();
                 } */
	    		type = 1;
                 $("#myteam-info-entry").empty();
	    		ajaxdata();
	    	}
	    })
   
</script>

</body>
</html>